//
//  CompanyPrivacySettingModel.m
//  Btpin
//
//  Created by Vic on 2019/3/30.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "CompanyPrivacySettingModel.h"

@implementation CompanyPrivacySettingModel

- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
    self.view = [UIToolsControl dataAnalysis:keyedValues[@"view"]];
    self.view_list = [NSMutableArray arrayWithCapacity:0];
    self.viewShow = @"";
    if (keyedValues[@"view_list"] && [keyedValues[@"view_list"] count]) {
        for (NSString *str in keyedValues[@"view_list"]) {
            [self.view_list addObject:str];
        }
        if (self.view_list.count) {
            NSString *str = self.view_list.firstObject;
            if ([DataToolsControl sharedManager].allCategoryInfoModel && [DataToolsControl sharedManager].allCategoryInfoModel.jobAllowListArray.count) {
                for (PublicCategoryElementModel *model in [DataToolsControl sharedManager].allCategoryInfoModel.jobAllowListArray) {
                    if ([model.id integerValue] == [str integerValue]) {
                        self.viewShow = model.name;
                        break;
                    }
                }
            }
        }
    }
    if (self.view && self.view.length) {
        if (([self.view integerValue]==1)) {
            self.viewShow = @"所有人";
        } else if (([self.view integerValue]==2)) {
            self.viewShow = @"部分人可查看";
        } else if (([self.view integerValue]==3)) {
            self.viewShow = @"禁止屏蔽企业查看";
        }
    }
    
    self.push = [UIToolsControl dataAnalysis:keyedValues[@"push"]];
    self.push_list = [NSMutableArray arrayWithCapacity:0];
    self.pushShow = @"";
    if (keyedValues[@"push_list"] && [keyedValues[@"push_list"] count]) {
        for (NSString *str in keyedValues[@"push_list"]) {
            [self.push_list addObject:str];
        }
        if (self.push_list.count) {
            NSString *str = self.push_list.firstObject;
            if ([DataToolsControl sharedManager].allCategoryInfoModel && [DataToolsControl sharedManager].allCategoryInfoModel.jobPushBanListArray.count) {
                for (PublicCategoryElementModel *model in [DataToolsControl sharedManager].allCategoryInfoModel.jobPushBanListArray) {
                    if ([model.id integerValue] == [str integerValue]) {
                        self.pushShow = model.name;
                        break;
                    }
                }
            }
        }
    }
    if (self.push && self.push.length) {
        if ([self.push integerValue]==1) {
            self.pushShow = @"所有人";
        } else if ([self.push integerValue]==2) {
            self.pushShow = @"推送给部分人";
        }
    }
    
    self.video = [UIToolsControl dataAnalysis:keyedValues[@"video"]];
    self.video_list = [NSMutableArray arrayWithCapacity:0];
    self.videoShow = @"";
    if (keyedValues[@"video_list"] && [keyedValues[@"video_list"] count]) {
        for (NSString *str in keyedValues[@"video_list"]) {
            [self.video_list addObject:str];
        }
        if (self.video_list.count) {
            NSString *str = self.video_list.firstObject;
            if ([DataToolsControl sharedManager].allCategoryInfoModel && [DataToolsControl sharedManager].allCategoryInfoModel.allowVideoListArray.count) {
                for (PublicCategoryElementModel *model in [DataToolsControl sharedManager].allCategoryInfoModel.allowVideoListArray) {
                    if ([model.id integerValue] == [str integerValue]) {
                        self.videoShow = model.name;
                        break;
                    }
                }
            }
        }
    }
    if (self.video && self.video.length) {
        if ([self.video integerValue]==1) {
            self.videoShow = @"所有人";
        } else {
            if ([self.video integerValue]==2) {
                self.videoShow = @"部分人";
            }
        }
    }
    
    self.display_name = [UIToolsControl dataAnalysis:keyedValues[@"display_name"]];
    self.display_name_cn = [UIToolsControl dataAnalysis:keyedValues[@"display_name_cn"]];
    
    self.push_bank_list = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"push_bank_list"] && [keyedValues[@"push_bank_list"] count]) {
        [self.push_bank_list addObjectsFromArray:keyedValues[@"push_bank_list"]];
    }
    
    self.shield_max = [UIToolsControl dataAnalysis:keyedValues[@"shield_max"]];
    
    self.shield_company = [NSMutableArray arrayWithCapacity:0];
    if (keyedValues[@"shield_company"] && [keyedValues[@"shield_company"] count]) {
        [self.shield_company addObjectsFromArray:keyedValues[@"shield_company"]];
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (id)copyWithZone:(NSZone *)zone {
    CompanyPrivacySettingModel *model = [[[self class] allocWithZone:zone] init];
    model.view = self.view;
    model.view_list = [NSMutableArray arrayWithCapacity:0];
    if (self.view_list && self.view_list.count) {
        [model.view_list addObjectsFromArray:self.view_list];
    }
    model.viewShow = self.viewShow;
    
    model.push = self.push;
    model.push_list = [NSMutableArray arrayWithCapacity:0];
    if (self.push_list && self.push_list.count) {
        [model.push_list addObjectsFromArray:self.push_list];
    }
    model.pushShow = self.pushShow;
    
    model.video = self.video;
    model.video_list = [NSMutableArray arrayWithCapacity:0];
    if (self.video_list && self.video_list.count) {
        [model.video_list addObjectsFromArray:self.video_list];
    }
    model.videoShow = self.videoShow;
    
    model.display_name = self.display_name;
    model.display_name_cn = self.display_name_cn;
    model.push_bank_list = [NSMutableArray arrayWithCapacity:0];
    if (self.push_bank_list && self.push_bank_list.count) {
        [model.push_bank_list addObjectsFromArray:self.push_bank_list];
    }
    
    model.shield_max = self.shield_max;
    model.shield_company = [NSMutableArray arrayWithCapacity:0];
    if (self.shield_company && self.shield_company.count) {
        [model.shield_company addObjectsFromArray:self.shield_company];
    }
    
    return model;
}

@end
